package com.wiz.vo.to;

import java.util.HashMap;
import java.util.Map;

import com.wiz.common.RandomStringGenerator;
import com.wiz.common.TencentConfigure;
import com.wiz.common.TencentSignature;


/**
 * 支付订单
 * @author Hakeny
 */
public class PayOrderTO extends BaseObject {
	private static final long serialVersionUID = 8229958693513011698L;

	
	private String payOrderId;//支付订单ID
	private String fuellingOrderId;//自身系统订单id
	private String refOrderId;//关联订单ID，来自三方
	private String prePayId;// 预支付订单Id
	private String codeUrl;// 二维码支付转换数据
	//web支付，网页签名参数
	private String appId;
	private String timeStamp;
	private String nonceStr;
	private String signType;
	private String paySign;
	
	public PayOrderTO(){}
	
	public PayOrderTO(int type){
		//微信分配的公众号ID（开通公众号之后可以获取到）
        setAppId(TencentConfigure.getAppid());
        //随机字符串，不长于32 位
        setNonceStr(RandomStringGenerator.getRandomStringByLength(32));
        setTimeStamp(String.valueOf(System.currentTimeMillis()/1000));
        setSignType("MD5");
	}
	
	/**
	 * 对web支付进行必要的参数签名，目前只运用于html上的JSAPI支付
	 */
	public void sign(String key){
		setPaySign(TencentSignature.getSign(toMap(),key));
	}
	
	private Map<String,Object> toMap(){
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("appId", appId);
        map.put("timeStamp", timeStamp);
        map.put("nonceStr", nonceStr);
        map.put("package", "prepay_id="+prePayId);
        map.put("signType", signType);
        return map;
    }

	public String getPayOrderId() {
		return payOrderId;
	}

	public void setPayOrderId(String payOrderId) {
		this.payOrderId = payOrderId;
	}

	public String getFuellingOrderId() {
		return fuellingOrderId;
	}

	public void setFuellingOrderId(String fuellingOrderId) {
		this.fuellingOrderId = fuellingOrderId;
	}

	public String getRefOrderId() {
		return refOrderId;
	}

	public void setRefOrderId(String refOrderId) {
		this.refOrderId = refOrderId;
	}

	public String getPrePayId() {
		return prePayId;
	}

	public void setPrePayId(String prePayId) {
		this.prePayId = prePayId;
	}

	public String getCodeUrl() {
		return codeUrl;
	}

	public void setCodeUrl(String codeUrl) {
		this.codeUrl = codeUrl;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(String timeStamp) {
		this.timeStamp = timeStamp;
	}

	public String getNonceStr() {
		return nonceStr;
	}

	public void setNonceStr(String nonceStr) {
		this.nonceStr = nonceStr;
	}

	public String getSignType() {
		return signType;
	}

	public void setSignType(String signType) {
		this.signType = signType;
	}

	public String getPaySign() {
		return paySign;
	}

	public void setPaySign(String paySign) {
		this.paySign = paySign;
	}


	
}
